<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/vue.js"></script>
</head>
<body>
    <div id="example">
        <div class="title">
            <div>姓名</div>
            <div>月收入</div>
            <div>专项扣除</div>
            <div>个税</div>
            <div>工资</div>
        </div>
    
        <div class="content" v-for="(value,index) in staff">
            <div>{{value.name}}</div>
            <div>{{value.income}}</div>
            <div>{{insurance}}</div>
            <div>{{wages[index]}}</div>
            <div>{{value.income-insurance-wages[index]}}</div>
        </div>
    </div>
    <script>
        var vm = new Vue({
            el:'#example',
            data:{
                insurance: 1000, //专项扣除费用
                threshold: 5000, //个税起征点
                tax: 0.03, //税率
                staff : [
                    {
                        name : "张大帅",
                        income: 6600,
                    },
                    {
                        name : "令元帅",
                        income: 7600,
                    },
                    {
                        name : "牛马哥",
                        income: 1300,
                    }
                ]
            },
            computed : {
                wages : function(){
                    var t = this;
                    var taxArr = [];
                    this.staff.forEach(function(s){
                        taxArr.push((s.income-t.threshold-t.insurance)*t.tax);
                        
                    });
                    return taxArr;//个税数组
                }
            }
        })

    </script>

    
</body>
</html>